<!DOCTYPE html>
<html class="x-admin-sm">

<head>
  <meta charset="UTF-8">
  <title>查看设备/终端库存</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <link rel="stylesheet" href="../../css/font.css">
  <link rel="stylesheet" href="../../css/xadmin.css">
  <script src="../../lib/layui/layui.js" charset="utf-8"></script>

  <script src="https://cdn.bootcss.com/moment.js/2.23.0/moment.min.js
		" type="text/javascript" charset="utf-8"></script>
  <script src="../../js/jquery.min.js" type="text/javascript" charset="utf-8"></script>
  <script src="../../js/app.js" type="text/javascript" charset="utf-8"></script>
  <style type="text/css">
    #page {
      display: flex;
      justify-content: center;
    }
  </style>
</head>

<body>
  <div class="x-nav">
    <span class="layui-breadcrumb">
      <a href="">首页</a>
      <a href="">演示</a>
      <a>
        <cite>导航元素</cite>
      </a>
    </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right"
      onclick="location.reload()" title="刷新">
      <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i></a>
  </div>
  <div class="layui-fluid">
    <div class="layui-row layui-col-space15">
      <div class="layui-col-md12">
        <div class="layui-card">
          <div class="layui-card-body ">

            <div class="layui-collapse" lay-filter="test">
              <div class="layui-colla-item">
                <h2 class="layui-colla-title">条件筛选<i class="layui-icon layui-colla-icon"></i></h2>
                <div class="layui-colla-content layui-show">
                  <form class="layui-form layui-col-space5" action="">

                    <div class="layui-input-inline layui-show-xs-block">
                      <select name="category" id="category" lay-filter="category">
                        <option value=""></option>
                      </select>
                    </div>
                    <div class="layui-input-inline layui-show-xs-block">
                      <select name="typical" id="typical" lay-filter="typical">

                      </select>
                    </div>

                    <div class="layui-input-inline layui-show-xs-block">
                      <select name="RepositoryName" id="RepositoryName" lay-filter="RepositoryName">

                      </select>
                    </div>

                    <div class="layui-inline layui-show-xs-block">
                      <button class="layui-btn" lay-submit="" lay-filter="sreach"><i class="layui-icon"
                          id="Search">&#xe615;</i>查询</button>
                    </div>
                  </form>
                </div>
              </div>
            </div>

          </div>
          <div class="layui-card-body ">
            <table class="layui-table layui-form">
              <thead id="Thead" class="layui-hide">
                <tr>
                  <th>种类名</th>
                  <th>品牌</th>
                  <th>型号</th>
                  <th>入库时间</th>
                  <th>串号</th>
                  <th>库存状态</th>
                </tr>
              </thead>
              <tbody id="Tbody">

              </tbody>
            </table>
          </div>
        </div>
      </div>
    </div>
  </div>

  <script src="check.js" type="text/javascript" charset="utf-8"></script>

  <script>
    layui.use(['laydate', 'form', 'layer', 'element'], function () {
      var laydate = layui.laydate;
      var form = layui.form;
      var layer = layui.layer;
      var element = layui.element;

      var Tbody = document.getElementById("Tbody");
      var category = document.getElementById("category");
      var brand = document.getElementById("brand");
      var typical = document.getElementById("typical");
      var Search = document.getElementById("Search");
      var Info = app.getUserGlobalInfo();

      form.on('submit(sreach)', function (data) {
        var result = data.field
        console.log(result)
        $.ajax({
          url: app.ServerUrl + 'v1/repository/getThingsInRepositoryByCondition',
          type: "get",
          contentType: "application/json;charset=UTF-8",
          dataType: "json",
          async: true,
          headers: {
            "Authorization": "460bcdb0-b326-4d6d-ac99-232c83ba6d80"
          },
          data: {
            categoryId: result.category,
            typicalId: result.typical,
            repositoryId: result.RepositoryName,
            userId: Info.userId
          },
          success: function (data) {
            console.log(data);
            var result = data.objs[0];
            if (result == '') {
              layer.open({
                content: '没有查到相关数据...',
                btnAlign: 'r',
                anim: 5,
                icon: 5,
                cancel: function () {},
              });
			  Tbody.innerHTML = '';
            } else {
              $('#Thead').removeClass('layui-hide');
              var Html = '';
              for (let i = 0; i < result.length; i++) {
                var singleInfo = result[i];
				console.log(singleInfo.storageTime)
                // var inTime = app.getFormatDate(singleInfo.inTime);
				 var inTime = app.getFormatDate(singleInfo.storageTime);
                var status = '在库中';
                if (singleInfo.status === '1') {
                  status = '已销毁'
                }
                Html += ' <tr> ' +
                  '<td>' + singleInfo.categoryName + '</td>' +
                  '<td>' + singleInfo.brand + '</td>' +
                  '<td>' + singleInfo.typicalModel + '</td>' +
                  '<td>' + inTime + '</td>' +
                  '<td>' + singleInfo.imei + '</td>' +
                  '<td>' + status + '</td>' +
                  '</tr>'
              }
              Tbody.innerHTML = Html;
            }
          },
          error: function (e) {
            layer.open({
              content: '查询失败！.',
              btnAlign: 'r',
              anim: 5,
              icon: 5,
              cancel: function () {}
            });
          }
        })
        return false;
      })

      //执行一个laydate实例
      laydate.render({
        elem: '#Time' //指定元素
      });

      //执行一个laydate实例
      laydate.render({
        elem: '#end' //指定元素
      });

    });
  </script>
  <script>
    var _hmt = _hmt || [];
    (function () {
      var hm = document.createElement("script");
      hm.src = "https://hm.baidu.com/hm.js?b393d153aeb26b46e9431fabaf0f6190";
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(hm, s);
    })();
  </script>
  <script type="text/javascript" src="../../js/xadmin.js"></script>
</body>

</html>